package com.tao.lab.event.dispath;

/**
 * @ProjectName: lab
 * @Package: com.tao.lab.event.dispath
 * @ClassName: Subscription
 * @Description: java类作用描述
 * @Author: wangxf
 * @CreateDate: 2022/5/6 11:56
 * @UpdateUser: 更新者
 * @UpdateDate: 2022/5/6 11:56
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class Subscription {
    final Object subscriber;
    final SubscriberMethod subscriberMethod;
    volatile boolean active;

    Subscription(Object subscriber, SubscriberMethod subscriberMethod) {
        this.subscriber = subscriber;
        this.subscriberMethod = subscriberMethod;
        this.active = true;
    }

    public boolean equals(Object other) {
        if (!(other instanceof Subscription)) {
            return false;
        } else {
            Subscription otherSubscription = (Subscription) other;
            return this.subscriber == otherSubscription.subscriber && this.subscriberMethod.equals(otherSubscription.subscriberMethod);
        }
    }

    public int hashCode() {
        return this.subscriber.hashCode() + this.subscriberMethod.methodString.hashCode();
    }
}
